<template>
  <a-modal v-model:visible="showVisible" title="日志详情" :footer="null" :width="800">
    <a-descriptions bordered :column="{ md: 2 }" size="small">
      <a-descriptions-item label="日志标题" :label-style="{ width: '120px' }">{{
        showDetail.title
      }}</a-descriptions-item>
      <a-descriptions-item label="日志类型" :label-style="{ width: '120px' }">
        <a-tag :color="showDetail.logType.color">{{ showDetail.logType.label }}</a-tag>
      </a-descriptions-item>
      <a-descriptions-item label="创建人">{{ showDetail.createBy }}</a-descriptions-item>
      <a-descriptions-item label="操作ip地址">{{ showDetail.remoteAddr }}</a-descriptions-item>
      <a-descriptions-item label="用户代理" :span="2"> {{ showDetail.userAgent }}</a-descriptions-item>
      <a-descriptions-item label="请求uri" :span="2">{{ showDetail.requestUri }}</a-descriptions-item>
      <a-descriptions-item label="操作方式"> {{ showDetail.method }}</a-descriptions-item>
      <a-descriptions-item label="方法执行时间">{{ showDetail.time }}</a-descriptions-item>
      <a-descriptions-item label="数据" :span="2">{{ showDetail.params }}</a-descriptions-item>
      <a-descriptions-item v-if="LogTypeEnum.ERROR.$eq(showDetail.logType.value)" label="异常信息" :span="2">
        {{ showDetail.exception }}</a-descriptions-item
      >
      <a-descriptions-item label="创建时间">{{ showDetail.createTime }}</a-descriptions-item>
    </a-descriptions>
  </a-modal>
</template>

<script name="SystemLogDetail" lang="ts" setup>
import { LogTypeEnum } from "@/enums/system";
const showVisible = ref<boolean>(false);
const showDetail = ref();
const show = (detail: any) => {
  showDetail.value = detail;
  showVisible.value = true;
};
defineExpose({ show });
</script>
